<script>
import indexJs from '@/jsInAppVue/index.js'
import i18nJs from "@/commonJs/i18n";
import userStore from "@/store/modules/user";

export default {
  created() {

  },
  onLaunch(e) {
    // 清理前缀是"requestNumber:"的缓存
    indexJs.clearRequestNumberCache();

    // 获取系统字典
    i18nJs.getDictI18nMapOfAppFront();

    userStore.requestUserInfoSelf();

    uni.getPushClientId({
      success: (resPush) => {
        console.log(resPush.cid, "getPushClientId");
        this.$request({
          url:"/socket-web/uniPush/bind",
          method:"POST",
          data:{
            cid:resPush.cid
          },
          success:(res)=>{
            console.log(res,"bind:success");
          },
          fail:(res)=>{
            console.log(res,"bind:fail");
          }
        });
      },
		fail:(res)=>{
		    console.log(JSON.stringify(res),"fail:getPushClientId")
	    }
    });

    uni.onPushMessage((res) => {
      // console.log(res, "onPushMessage");
      let json = res.data.payload;
      console.log(json, "onPushMessage:json");
      uni.$emit(json.emit, json.data);

      if(json.emit=="busDtuStatusUpdate"){
        uni.$emit("busDtuStatusUpdate:"+json.data.imei, json.data);
      }
    });

  },
  onShow: function () {
  },
  onHide: function () {
  },
  methods: {
  }
}
</script>

<style>
/*每个页面公共css */
</style>
